package com.thinkgem.jeesite.modules.sys.service;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.product.dao.attribute.TbProductAttributeDao;
import com.thinkgem.jeesite.modules.product.entity.attribute.TbProductAttribute;
import com.thinkgem.jeesite.modules.sys.dao.*;
import com.thinkgem.jeesite.modules.sys.entity.*;
import com.thinkgem.jeesite.modules.sys.utils.DateTimeUtils;
import com.thinkgem.jeesite.modules.sys.utils.UploadDemo;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import org.mozilla.javascript.EcmaError;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBulletSizePoint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.MultiValueMap;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * Created by WAjava on 2016-10-21.
 */
@Service
@Transactional(readOnly = true)
public class ProductService {
    @Autowired
    private TbQiNiuMapper tbQiNiuMapper;
    @Autowired
    private TbProductMapper tbProductMapper;
    @Autowired
    private TbAttachmentMapper tbAttachmentMapper;

    @Autowired
    private TbAgentProductMapper tbAgentProductMapper;
    @Autowired
    private TbProductAttributeDao tbProductAttributeDao;
    @Autowired
    private TbAgentProductDao tbAgentProductDao;
    @Autowired
    private TbCategoryDao tbCategoryDao;

    @Autowired
    private TbCategoryDao TbCategoryDao;

    public Page<TbProduct> findProductByPage(Page<TbProduct> tbProductPage, TbProduct tbProduct) {
        tbProduct.setPage(tbProductPage);
        //商品管理list
        List list = tbProductMapper.findByPage(tbProduct);
        for(int i=0;i<list.size();i++){
            TbProduct t=(TbProduct)list.get(i);
           //根据商品id得到集合信息
            List<TbAgentProduct> agentProductList = tbAgentProductMapper.getAgentProductByProIdAndAgentId(t.getId(),UserUtils.getUser().getId());
            t.setTbAgentProduct(agentProductList);
            List<TbProductAttribute> attrList=tbAgentProductDao.queryProductAttributeList(t.getId()+"");
            t.setProductAttr(attrList);
        }
        //根据商品id得到属性
        tbProductPage.setList(list);
        return tbProductPage;
    }
    @Transactional(readOnly = false)
    public int saveOrUpdateProduct(TbProduct tbProduct) {
        Date nowTime = new Date();
        tbProduct.setUpdateTime(nowTime);
        User user = UserUtils.getUser();
        List<TbAgentProduct> tbAgentProductList = tbAgentProductMapper.getAgentProductByProIdAndAgentId(tbProduct.getId(), user.getId());
        int result = 0;
        try{
            if("on".equals(tbProduct.getGender())){
                tbProduct.setGender("1");
                tbProduct.setReserveEndTime(translate(tbProduct.getReserveEndTime02()));
                tbProduct.setReserveStartTime(translate(tbProduct.getReserveStartTime02()));
            }else{
                tbProduct.setGender("0");
                tbProduct.setReserveEndTime(DateTimeUtils.getDateYYYY_MM_DD_HH_MM_SS(tbProduct.getReserveEndTime01()));
                tbProduct.setReserveStartTime(DateTimeUtils.getDateYYYY_MM_DD_HH_MM_SS(tbProduct.getReserveStartTime01()));
            }
        }catch (Exception e){

        }
        if (null != tbProduct.getId() && !"".equals(tbProduct.getId())) {//执行更新
            if(tbAgentProductList.size()!=0){
                for(TbAgentProduct  list:tbAgentProductList){
                    tbAgentProductMapper.deleteByPrimaryKey(list.getId());
                }
                TbCategory tbCategory = tbCategoryDao.get(tbProduct.getCategoryId());
                if(!"2".equals(tbProduct.getCategoryId())||!"3".equals(tbProduct.getCategoryId())||!"4".equals(tbProduct.getCategoryId())){
                    String cateforyId = tbCategory.getParentIds().substring(4,5);
                    if("2".equals(cateforyId)||"3".equals(cateforyId)||"4".equals(cateforyId)){
                        tbProduct.setReserveFlag(cateforyId);
                    }
                }else{
                        tbProduct.setReserveFlag(tbProduct.getCategoryId());
                }
                result = tbProductMapper.updateByPrimaryKeySelective(tbProduct);
                List<TbProductAttributeGroup> listAttr = tbProduct.getProductAttrGroup();
                for (TbProductAttributeGroup listattr:listAttr){
                    if(listattr.getUnit()!=null&&listattr.getUnit()!=null&&listattr.getStoreNum()!=null){
                        TbAgentProduct tbAgentProduct = new TbAgentProduct();
                        tbAgentProduct.setStoreNum(listattr.getStoreNum());
                        tbAgentProduct.setAlertStoreNum(listattr.getAlertStoreNum());
                        tbAgentProduct.setAttr(listattr.getSku());
                        tbAgentProduct.setUnit(listattr.getUnit());
                        tbAgentProduct.setPrice(listattr.getPrice());
                        tbAgentProduct.setUpdateTime(nowTime);
                        tbAgentProduct.setAgentId(user.getId());
                        tbAgentProduct.setIsDelete((byte) 0);
                        tbAgentProduct.setStatus((byte) 0);
                        tbAgentProduct.setCreateTime(nowTime);
                        tbAgentProduct.setProductId(tbProduct.getId());
                        tbAgentProductMapper.insertSelective(tbAgentProduct);
                    }
                }
            }
        }else {//

            tbProduct.setCreateTime(nowTime);
            TbCategory tbCategory = tbCategoryDao.get(tbProduct.getCategoryId());
            if(!"2".equals(tbProduct.getCategoryId())||!"3".equals(tbProduct.getCategoryId())||!"4".equals(tbProduct.getCategoryId())){
                String cateforyId = tbCategory.getParentIds().substring(4,5);
                if("2".equals(cateforyId)||"3".equals(cateforyId)||"4".equals(cateforyId)){
                    tbProduct.setReserveFlag(cateforyId);
                }
            }else{
                tbProduct.setReserveFlag(tbProduct.getCategoryId());
                tbProduct.setWholesalePrice(new BigDecimal("0"));
            }
            result = tbProductMapper.insertSelective(tbProduct);
            List<TbProductAttributeGroup> listAttr = tbProduct.getProductAttrGroup();
            for (TbProductAttributeGroup listattr:listAttr){
                TbAgentProduct tbAgentProduct = new TbAgentProduct();
                tbAgentProduct.setStoreNum(listattr.getStoreNum());
                tbAgentProduct.setAlertStoreNum(listattr.getAlertStoreNum());
                tbAgentProduct.setAttr(listattr.getSku());
                tbAgentProduct.setUnit(listattr.getUnit());
                tbAgentProduct.setPrice(listattr.getPrice());
                tbAgentProduct.setUpdateTime(nowTime);
                tbAgentProduct.setAgentId(user.getId());
                tbAgentProduct.setIsDelete((byte) 0);
                tbAgentProduct.setStatus((byte) 0);
                tbAgentProduct.setCreateTime(nowTime);
                tbAgentProduct.setProductId(tbProduct.getId());
                tbAgentProductMapper.insertSelective(tbAgentProduct);
            }
        }
        TbProductAttribute tbProductAttribute = new TbProductAttribute();
        tbProductAttribute.setProductId(tbProduct.getId());
        List<TbProductAttribute> persists = this.tbProductAttributeDao.findList(tbProductAttribute);
        if (!persists.isEmpty()) {
            for (TbProductAttribute attribute : persists) {
                this.tbProductAttributeDao.delete(attribute);
            }
        }
        List<TbProductAttribute> attributes = tbProduct.getProductAttr();
        if (attributes != null && !attributes.isEmpty()) {
            for (TbProductAttribute attribute : attributes) {
                attribute.setProductId(tbProduct.getId());
                if (StringUtils.isEmpty(attribute.getProductAttr())
                        || StringUtils.isEmpty(attribute.getProductAttrOption())
                        || StringUtils.isEmpty(attribute.getProductAttrValue())) {
                    continue;
                }
                this.tbProductAttributeDao.insert(attribute);
            }
        }
        return tbProduct.getId();
    }

    public List<TbAgentProduct> getTbAgentProduct(int productId) {
        User user = UserUtils.getUser();
        String userId = user.getId();
        List<TbAgentProduct> tbAgentProduct = tbAgentProductMapper.getAgentProductByProIdAndAgentId(productId, userId);
        return tbAgentProduct;
    }
    //根据条形码判断商品是否存在
    @Transactional(readOnly = false)
    public TbProduct selectProductBybarcode(String barcode,String reverflag){
        //根据条形码判断该商品是否存在，如果存在则修改，不存在新增
        //根据商品类别id查询得到商品的父级
        TbCategory tbCategory=TbCategoryDao.get(reverflag);
        String id=tbCategory.getParentIds();
        TbProduct tbProduct=new TbProduct();
        tbProduct.setBarcode(barcode);
        //如果父级长度不等于4或6，则截取4,5位的值为商品类别，，否则则用id作为类别
        if(id.length()==4||id.length()==2){
            tbProduct.setReserveFlag(tbCategory.getId());
        }else{
            id=id.substring(4,5);
            tbProduct.setReserveFlag(id);
        }
        return tbProductMapper.selectProductBybarcode(tbProduct);
    }
    @Transactional(readOnly = false)
    public TbCategory getTbCategory(String id) {

        return TbCategoryDao.get(id);
    }


    public TbProduct get(Integer id) {
        List<TbProduct>list = tbProductMapper.selectByPrimaryKey(id);
        if(list.size()!=0){
            TbProduct tbProduct = tbProductMapper.selectByPrimaryKey(id).get(0);
            //根据商品id得到集合信息
            List<TbAgentProduct> agentProductList = tbAgentProductMapper.getAgentProductByProIdAndAgentId(tbProduct.getId(),UserUtils.getUser().getId());
            tbProduct.setTbAgentProduct(agentProductList);
            List<TbProductAttribute> attrList=tbAgentProductDao.queryProductAttributeList(tbProduct.getId()+"");
            tbProduct.setProductAttr(attrList);
            return tbProduct;
        }else{
            TbProduct tbProduct = new TbProduct();
            List<TbAgentProduct> agentProductList = tbAgentProductMapper.getAgentProductByProIdAndAgentId(tbProduct.getId(),UserUtils.getUser().getId());
            tbProduct.setTbAgentProduct(agentProductList);
            return tbProduct;
        }
    }

    @Transactional(readOnly = false)
    public void delete(TbProduct tbProduct) {
        //这里删除的应该是agent_product。
//        tbProduct.setIsDelete(new Byte("1"));
//        tbProductMapper.updateByPrimaryKey(tbProduct);

        TbAgentProduct tbAgentProduct = new TbAgentProduct();
        tbAgentProduct.setIsDelete(new Byte("1"));

        TbAgentProductExample tbAgentProductExample = new TbAgentProductExample();
        TbAgentProductExample.Criteria criteria = tbAgentProductExample.createCriteria();
        criteria.andProductIdEqualTo(tbProduct.getId());
        this.tbAgentProductMapper.updateByExampleSelective(tbAgentProduct, tbAgentProductExample);

    }

    /**
     * 上传商品图片
     *
     * @param multiFileMap
     * @param request
     * @return
     */
    @Transactional(readOnly = false)
    public List<String> uploadMulFile(MultiValueMap<String, MultipartFile> multiFileMap, HttpServletRequest request) {
        List<String> urlList = new ArrayList<String>();
        TbQiNiuAccount tbQiNiuAccount = new TbQiNiuAccount();
        tbQiNiuAccount.setType("H5");
        TbQiNiuAccount account = tbQiNiuMapper.selectByType(tbQiNiuAccount);
        List<String> paths = new ArrayList<String>();
        for (String key : multiFileMap.keySet()) {
            List<MultipartFile> MultipartFiles = multiFileMap.get(key);
            for (MultipartFile file : MultipartFiles) {
                try {
                    String fileName = file.getOriginalFilename();
                    UUID uuid = UUID.randomUUID();
                    String uuidStr = uuid.toString();
                    int beginIndex = fileName.lastIndexOf(".");
                    String suffix = fileName.substring(beginIndex);
                    UploadDemo uploadDemo = new UploadDemo();
                    uploadDemo.setAccessKey(account.getAccessKey());
                    uploadDemo.setSecretKey(account.getSecretKey());
                    uploadDemo.setBucketName(account.getBucketName());
                    uploadDemo.setDomain(account.getDomain());

                    uploadDemo.uploadFile(uuidStr + suffix, file.getInputStream());

                    String downloadUrl = uploadDemo.getDownloadFileUrl(uuidStr + suffix);
                    //截取拼接字符串
                    String Url = downloadUrl.substring(0, downloadUrl.indexOf(suffix));
                    String url = Url + suffix;
                    urlList.add(url);
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }
        }
        return urlList;
    }

    @Transactional(readOnly = false)
    public void insertProductImg(int id, List<String> uploadUrl) {

        //delete old pics
        List<TbAttachment> list = tbAttachmentMapper.selectByFkId(id);
        if (list.size() != 0) {
            for (int i = 0; i < list.size(); i++) {
                this.tbAttachmentMapper.deleteByPrimaryKey(list.get(i).getId());
            }
        }

        if (uploadUrl == null || uploadUrl.size() == 0) {
            return;
        }

        //add new pics
        TbAttachment attachment = new TbAttachment();
        attachment.setFkId(id);
        attachment.setTbName("TbProduct");
        for (int i = 0; i < uploadUrl.size(); i++) {
            if (i == 0) {
                attachment.setIsMain("1");
                attachment.setImageUrl(uploadUrl.get(i));
                tbAttachmentMapper.insert(attachment);
            } else {
                attachment.setIsMain("0");
                attachment.setImageUrl(uploadUrl.get(i));
                tbAttachmentMapper.insert(attachment);
            }
        }
    }


    public Page<TbProduct> findByPage(Page<TbProduct> tbProductPage, TbProduct tbProduct) {
        tbProduct.setPage(tbProductPage);
        //商品管理list
        List list = tbProductMapper.findByProPage(tbProduct);
        for(int i=0;i<list.size();i++){
            TbProduct t=(TbProduct)list.get(i);
            //根据商品id得到集合信息
            List<TbAgentProduct> agentProductList = tbAgentProductMapper.getAgentProductByProIdAndAgentId(t.getId(),UserUtils.getUser().getId());
            t.setTbAgentProduct(agentProductList);
            List<TbProductAttribute> attrList=tbAgentProductDao.queryProductAttributeList(t.getId()+"");
            t.setProductAttr(attrList);
        }
        //根据商品id得到属性
        tbProductPage.setList(list);
        return tbProductPage;
    }
    public Date translate(String string)throws Exception{
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
        Date date = sdf.parse(string);
        date.setMonth(3);
        date.setYear(71);
        return date;
    }
    //将要导入的商品信息存放到商品表中
    public TbProduct useProduct( TbProductImport tbProductImport,TbCategory reserveFlag,TbCategory categoryName){
        TbProduct tbProduct=new TbProduct();
        tbProduct.setReserveFlag(reserveFlag.getId());
        tbProduct.setCategoryId(categoryName.getId());
        tbProduct.setTitle(tbProductImport.getTitle());
        tbProduct.setSize(tbProductImport.getSize());
        tbProduct.setProSort(tbProductImport.getProSort());
        tbProduct.setBarcode(tbProductImport.getBarcode());
        //预定生活商品不维护库存
        if(reserveFlag.getId().equals("3")){
            tbProduct.setIsMaintainStoreNum(0);
            tbProduct.setGender(tbProductImport.getGender()+"");
            //如果不是每天预定，处理时间为年月日
            //if(null!=tbAgentProduct.getGender()||!"".equals(tbProductImport.getGender())) {
            if ("0".equals(tbProductImport.getGender())) {
                tbProduct.setReserveStartTime(DateTimeUtils.getDateYYYY_MM_DD_HH_MM_SS(tbProductImport.getReserveStartTime()));
                tbProduct.setReserveEndTime(DateTimeUtils.getDateYYYY_MM_DD_HH_MM_SS(tbProductImport.getReserveEndTime()));
            } else if("1".equals(tbProductImport.getGender())){//如果是每天预定，则时间为时分
                tbProduct.setReserveStartTime(DateTimeUtils.getDateYYYY_MM_DD_HH_MM_SS(tbProductImport.getReserveStartTime()));
                Date da=tbProduct.getReserveStartTime();
                da.setYear(71);
                da.setMonth(3);
                tbProduct.setReserveStartTime(da);
                tbProduct.setReserveEndTime(DateTimeUtils.getDateYYYY_MM_DD_HH_MM_SS(tbProductImport.getReserveEndTime()));
                Date das=tbProduct.getReserveEndTime();
                das.setYear(71);
                das.setMonth(3);
                tbProduct.setReserveEndTime(das);
            }
            // }
        }else{
            tbProduct.setIsMaintainStoreNum(1);
            tbProduct.setGender("0");
        }
        Date date=new Date();
        tbProduct.setCreateTime(date);
        tbProduct.setUpdateTime(date);
        tbProduct.setStatus(new Byte("0"));
        tbProduct.setIsDelete(new Byte("0"));
        tbProduct.setIsUseMqWallet(new Byte(tbProductImport.getIsTenement()));
        return tbProduct;
    }
    //将要导入的信息存放到代理商商品表中
    public TbAgentProduct useTbAgentProduct(TbProductImport tbProductImport){
        TbAgentProduct tbAgentProduct=new TbAgentProduct();
        Date date=new Date();
        tbAgentProduct.setAlertStoreNum(tbProductImport.getIsAlertStoreNum());
        tbAgentProduct.setIsUseMqWallet(new Byte(tbProductImport.getIsTenement()));
        tbAgentProduct.setPrice(tbProductImport.getPrice());
        tbAgentProduct.setStoreNum(tbProductImport.getStoreNum());
        tbAgentProduct.setAlertStoreNum(tbProductImport.getIsAlertStoreNum());
        tbAgentProduct.setAgentId(UserUtils.getUser().getId());
        tbAgentProduct.setCreateTime(date);
        tbAgentProduct.setUpdateTime(date);
        tbAgentProduct.setIsDelete(new Byte("0"));
        tbAgentProduct.setStatus(new Byte("0"));
        tbAgentProduct.setAttr(tbProductImport.getAttr());
        tbAgentProduct.setUnit(tbProductImport.getProNum());
        return tbAgentProduct;
    }
    //导入商品信息
    @Transactional(readOnly = false)
    public String importProduct(List<TbProductImport> list){
        int successNum = 0;
        int failureNum = 0;
        StringBuilder failureMsg = new StringBuilder();
        try{
        for(int i=0;i<list.size();i++){
            TbProductImport tbProductImport=list.get(i);
            if(tbProductImport!=null){
                //判断商品属于便利生活还是生活预定,根据名称查询到类别
                List<TbCategory> listTbCategory=tbProductMapper.getCategory(tbProductImport.getReserveFlag());;

                if(!listTbCategory.isEmpty()){
                    TbCategory reserveFlag=listTbCategory.get(0);
                    if("1".equals(reserveFlag.getTarget())){
                        //类别名称
                        List<TbCategory> ListcategoryName=tbProductMapper.getCategory(tbProductImport.getCatetoryName());

                        if(!ListcategoryName.isEmpty()){
                            TbCategory categoryName=ListcategoryName.get(0);
                            //条形码是否存在
                            if(tbProductImport.getBarcode()!=null){
                                //根据条形码查询商品是否存在，在商品表中，商品条形码是唯一的
                                //商品的不同属性是在代理商商品表中以不同的商品体现
                                TbProduct tb=tbProductMapper.selecProductByBarcod(tbProductImport.getBarcode());
                                //将商品信息存到代理商商品表中
                                TbAgentProduct tbAgentProduct=useTbAgentProduct(tbProductImport);
                                if(null==tb){//如果商品不存在，则添加到商品表中
                                    TbProduct tbProduct=useProduct(tbProductImport,reserveFlag,categoryName);
                                    //商品添加到商品表后，添加到代理商商品表中
                                    tbProductMapper.insertSelective(tbProduct);
                                    tbAgentProduct.setProductId(tbProduct.getId());
                                    tbAgentProductMapper.insertSelective(tbAgentProduct);
                                    successNum++;
                                }else{//如果商品在商品表中存在，则判断在代理商商品表中是否存在
                                    //将商品表中的信息更新
                                    TbProduct tbProduct=useProduct(tbProductImport,reserveFlag,categoryName);
                                    //根据查询得到的id进行数据更新
                                    tbProduct.setId(tb.getId());
                                    tbProduct.setUpdateTime(new Date());
                                    //将已经存在的商品进行更新
                                    tbProductMapper.updateByPrimaryKeySelective(tbProduct);

                                    //1.代理商id，商品id，商品属性三个条件
                                    TbAgentProduct tbAgentPro=new TbAgentProduct();
                                    tbAgentPro.setProductId(tb.getId());
                                    tbAgentPro.setAgentId(UserUtils.getUser().getId());
                                    List<TbAgentProduct> agentProductList=tbAgentProductMapper.getAgentProductByAttr(tbAgentPro);
                                    tbAgentProduct.setProductId(tb.getId());
                                    //如果商品不存在，则添加到代理商商品表中
                                    if(agentProductList.size()==0){
                                        tbAgentProductMapper.insertSelective(tbAgentProduct);
                                        successNum++;
                                    }else{
                                        //根据代理商id，商品id，属性判断商品是否存在，如果不存在，则添加
                                        tbAgentPro.setAttr(tbProductImport.getAttr());
                                        List<TbAgentProduct> isExist=tbAgentProductMapper.getAgentProductByAttr(tbAgentPro);
                                        if(isExist.size()==0){
                                            tbAgentProductMapper.insertSelective(tbAgentProduct);
                                            successNum++;
                                            failureMsg.append("<br/>第"+(i+1)+"行"+tbProductImport.getTitle()+" 导入成功!");
                                        }else{//如果商品存在则更新
                                            //更新时将库存进行累加
                                            TbAgentProduct updateAgentProduct=useTbAgentProduct(tbProductImport);
                                            updateAgentProduct.setId(isExist.get(0).getId());
                                            updateAgentProduct.setProductId(tb.getId());
                                            updateAgentProduct.setUpdateTime(new Date());
                                            updateAgentProduct.setStatus(isExist.get(0).getStatus());
                                            //根据代理商商品id进行更新数据信息
                                            tbAgentProductMapper.updateForImportProduct(updateAgentProduct);
                                            successNum++;
                                            failureMsg.append("<br/>第"+(i+1)+"行"+tbProductImport.getTitle()+" 导入成功：该商品已经存在，已被新的商品信息覆盖！");
                                        }
                                    }
                                }

                            }else{
                                failureMsg.append("<br/>第"+(i+1)+"行"+tbProductImport.getTitle()+" 导入失败：条形码为必填项！");
                                failureNum++;
                                continue;
                            }
                        }else{
                            failureMsg.append("<br/>第"+(i+1)+"行"+tbProductImport.getTitle()+" 导入失败：类别名称不存在！");
                            failureNum++;
                            continue;
                        }
                    }else{
                        failureMsg.append("<br/>第"+(i+1)+"行"+tbProductImport.getTitle()+" 导入失败：所属类别错误！便利生活或生活预定");
                        failureNum++;
                        continue;
                    }
                }else{
                    failureMsg.append("<br/>第"+(i+1)+"行"+tbProductImport.getTitle()+" 导入失败：所属类别不存在！");
                    failureNum++;
                    continue;
                }

            }
        }  }catch (Exception e){
            e.printStackTrace();
        }

        //根据条形码或商品名称判断该商品是否存在，tb_product
        //1.tb_product 存在，则判断在tb_agent_procut中是否存在，
        // 1.1tb_agent_product如果存在，则判断属性是否相同，如果属性相同，则跳过，
        // 1.2不存则添加
        // 2，不存在则添加进去tb_product,tb_agent_product
        if (failureNum>0){
            failureMsg.insert(0, "失败 "+failureNum+" 条商品信息！");
        }else{
            failureMsg.append("<br/>已成功导入 "+successNum+" 条商品信息");
        }
        return failureMsg.toString();
    }
}
